import Vue from 'vue'
import Vuex from 'vuex'
import todoMain from './moudles/todoMain'
import todoFooter from './moudles/todoFooter'
import todoHeader from './moudles/todoHeader'
Vue.use(Vuex)

const store = new Vuex.Store({
    modules:{
        todoMain,
        todoFooter,
        todoHeader
    },
    getters:{
        list:(state)=>state.todoMain.list,
        value:(state)=>state.todoHeader.value,
        residue:(state)=>{
            const sum=state.todoMain.list.reduce((sum,item)=>{
                if(item.isDone==false){
                    sum++
                }
                return sum
            },0)
            return sum
        },
        judge:(state)=>state.todoFooter.judge


    }
})

export default store